<template>
	<view style="margin-left: 15px;margin-right: 15px;margin-top: 5%;">
		<u-select v-model="show" mode="mutil-column-auto" :list="list" @confirm="confirm"></u-select>
		<u-button @click="show = true" type="primary" style="margin-bottom: 3%;">筛选成绩</u-button>
		<text style="font-size: 45rpx;color: #00bebe;" v-if="title==''">所有成绩：</text>
		<text style="font-size: 45rpx;" v-if="title!=''">{{title}}:</text>
		<u-collapse :accordion="false" style="margin-bottom: 3%">
			<u-collapse-item :title="item.course.courseName" v-for="(item, index) in scores" :key="index">
				<u-tag text="合格" type="success" v-if="item.gpa>=1"/>
				<u-tag text="不合格" type="warning" v-if="item.gpa<1 && item.gpa!=null"/>
				<u-tag text="暂无成绩" type="primary" v-if="item.gpa==null"/>
				<text>考试成绩:{{item.testScore}}&nbsp;&nbsp;平时成绩:{{item.usualScore}}&nbsp;&nbsp;绩点:{{item.gpa}}&nbsp;&nbsp;学分:{{item.credit}}</text>	
			</u-collapse-item>
		</u-collapse>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scores: [],
				title:'',
				scoreVo: {
					page: 1,
					score: {
						term: '',
						student: {
							id: ''
						},
						pass:'',
						fail:''
					}
				},
				show: false,
				list: [{
						value: 1,
						label: '大一',
						children: [{
								value: 1,
								label: '上学期',
								children: [{
										value: 'pass',
										label: '合格'
									},
									{
										value: 'fail',
										label: '不合格'
									}
								]
							},
							{
								value: 2,
								label: '下学期',
								children: [{
										value: 'pass',
										label: '合格'
									},
									{
										value: 'fail',
										label: '不合格'
									}
								]
							}

						]
					},
					{
						value: 2,
						label: '大二',
						children: [{
								value: 1,
								label: '上学期',
								children: [{
										value: 'pass',
										label: '合格'
									},
									{
										value: 'fail',
										label: '不合格'
									}
								]
							},
							{
								value: 2,
								label: '下学期',
								children: [{
										value: 'pass',
										label: '合格'
									},
									{
										value: 'fail',
										label: '不合格'
									}
								]
							}
						]
					},
					{
						value: 3,
						label: '大三',
						children: [{
								value: 1,
								label: '上学期',
								children: [{
										value: 'pass',
										label: '合格'
									},
									{
										value: 'fail',
										label: '不合格'
									}
								]
							},
							{
								value: 2,
								label: '下学期',
								children: [{
										value: 'pass',
										label: '合格'
									},
									{
										value: 'fail',
										label: '不合格'
									}
								]
							}
						]
					},
					{
						value: 4,
						label: '大四',
						children: [{
								value: 1,
								label: '上学期',
								children: [{
										value: 'pass',
										label: '合格'
									},
									{
										value: 'fail',
										label: '不合格'
									}
								]
							},
							{
								value: 2,
								label: '下学期',
								children: [{
										value: 'pass',
										label: '合格'
									},
									{
										value: 'fail',
										label: '不合格'
									}
								]
							}
						]
					},
				]
			}
		},
		methods: {
			confirm(e) {
				this.title = e[0].label+e[1].label+"成绩";
				this.scoreVo.score.term = ""+e[0].value+e[1].value;
				if(e[2].label=='合格'){
					this.scoreVo.score.pass="true";
					this.scoreVo.score.fail="";
				}else{
					this.scoreVo.score.pass="";
					this.scoreVo.score.fail="true";
				}
				this.$axios.post("/api/v1/student/score/condition", this.scoreVo).then(res => {
					this.scores = res.data.data.data;
				});

			}
		},
		created() {
			this.scoreVo.score.student.id=uni.getStorageSync("studentId");
			this.$axios.post("/api/v1/student/score/condition", this.scoreVo).then(res => {
				this.scores = res.data.data.data;
			});
		}
	}
</script>

<style>

</style>
